/*
 * Copyright (c) 2016 zhangcm. All Rights Reserved.
 */
package com.jnzc.ocr.serv.shop.api.impl;

import com.jnzc.ocr.serv.shop.api.ShopUserApi;
import com.jnzc.ocr.serv.shop.entity.ShopUser;
import com.jnzc.ocr.serv.shop.entity.ShopUserRela;
import com.jnzc.ocr.serv.shop.service.ShopUserService;
import com.jnzc.ocr.serv.shop.vo.ShopUserCreateVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author zhangcm
 * @version 1.0, 2017/8/31
 */
@RestController
public class ShopUserApiImpl implements ShopUserApi {

    @Autowired
    private ShopUserService shopUserService;

    @Override
    public ShopUser find(@RequestParam("userId") Long userId) {
        return shopUserService.find(userId);
    }

    @Override
    public List<ShopUserRela> listShopRela(@RequestParam("userId") Long userId) {
        return shopUserService.listShopRela(userId);
    }

    public ShopUser create(@RequestBody ShopUserCreateVo param) {
        ShopUser shopUser = param.getShopUser();
        shopUserService.insert(shopUser, param.getShopMainList());
        return shopUser;
    }

    @Override
    public ShopUser update(@RequestBody ShopUser obj) {
        shopUserService.update(obj);
        return obj;
    }
}
